/**
 * Created by zhourh on 2018/9/10.
 */
public class Printer {

    public static <T> void printArray(T[] array) {
        if (array == null || array.length == 0) {
            System.out.println("");
        }

        System.out.print("[");
        for (int i = 0; i < array.length; i++) {
            T t = array[i];
            System.out.print(i == 0 ? t : ", " + t);
        }

        System.out.println("]");
    }

    public static void printIntArray(int[] array) {
        if (array == null || array.length == 0) {
            System.out.println("");
        }

        System.out.print("[");
        for (int i = 0; i < array.length; i++) {
            int t = array[i];
            System.out.print(i == 0 ? t : ", " + t);
        }

        System.out.println("]");
    }

    public static void printInt2Array(int[][] arrays) {
        for (int[] array : arrays) {
            printIntArray(array);
        }
    }

    public static void printTreeNode(TreeNode root) {
        System.out.println(TreeNode.treeNodeToString(root));
    }
}
